import 'package:flutter/material.dart';
import 'package:Lter/model/app.dart';
import 'package:Lter/screens/login/login_page.dart';

class LoginScreen extends StatefulWidget {
  @override
  _LoginScreenState createState() => _LoginScreenState();
}

class _LoginScreenState extends State<LoginScreen> {
  @override
  Widget build(BuildContext context) {
    /**
     * 根据是否有用户登录信息进入登录注册页面或者主页
        利用inheritedWidget，可以读取到父控件分享的数据
     */
    AppInherited app = AppContainer.of(context).app;
    if (app.mUser.username == "") {
      return LoginPage();
    } else {
      return Scaffold(
        body: Container(
          child: Center(
            child: Text(
                "用户已登录\n用户名:${app.mUser.username}\n密码：${app.mUser.password}"),
          ),
        ),
      );
    }
  }
}
